package com.springboot.cloud.demos.feign.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.common.core.exception.SystemErrorType;
import com.springboot.cloud.demos.feign.service.WeiXinApiService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WeiXinApiController {

    @Autowired
    private WeiXinApiService weiXinApiService;
    @PostMapping("/weixin/getwxacodeunlimit")
    public Result getwxacodeunlimit(@RequestBody String body) {
        String fileKey = DigestUtils.md5Hex(body);
        try {
            String url= weiXinApiService.getwxacodeunlimit( fileKey,  body);
            if(StringUtils.isNotEmpty(url)){
                return Result.success(url);
            }
        } catch (Exception e) {
            return Result.fail();
        }
        return Result.fail();
    }

}
